package com.hustzp.com.xichuangzhu.me;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.hustzp.com.xichuangzhu.R;
import com.hustzp.com.xichuangzhu.XichuangzhuApplication;
import com.hustzp.com.xichuangzhu.widget.FontTextView;

/**
 * Created by Administrator on 2016/6/5.
 */
public class SwitchFontStyleActivity extends MyBaseActivity {

    private TextView simpleFont;
    private TextView complexFont;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_switch_font_style);

        initToolbar();
        initViews();
    }

    private void initToolbar() {
        TextView navTxt = (TextView) findViewById(R.id.tv_nav_txt);
        navTxt.setText(getString(R.string.setting));
        TextView appTitle = (TextView) findViewById(R.id.tv_title_txt);
        appTitle.setText(getString(R.string.set_zhailv_zit));
    }

    private void initViews() {
        simpleFont = (TextView) findViewById(R.id.choose_simple_font);
        complexFont = (TextView) findViewById(R.id.choose_complex_font);
        FontTextView wenyuefont = (FontTextView) findViewById(R.id.wenyue_font);
        FontTextView huawen = (FontTextView) findViewById(R.id.huawen_font);
        wenyuefont.setTypeface(0);
        huawen.setTypeface(1);
        int fsv = XichuangzhuApplication.getInstance().getFontStyle();
        if (fsv == 0) {
            // 文悦古体仿宋
            simpleFont.setVisibility(View.VISIBLE);
            complexFont.setVisibility(View.GONE);
        } else {
            //华文仿宋
            complexFont.setVisibility(View.VISIBLE);
            simpleFont.setVisibility(View.GONE);
        }

    }

    public void clickView(View view) {
        switch (view.getId()) {
            case R.id.simple_font_btn:
                simpleFont.setVisibility(View.VISIBLE);
                complexFont.setVisibility(View.GONE);
                XichuangzhuApplication.getInstance().saveFontStyle(0);
                XichuangzhuApplication.getInstance().textTypefaceChangeNotify();
                break;
            case R.id.complex_font_btn:
                complexFont.setVisibility(View.VISIBLE);
                simpleFont.setVisibility(View.GONE);
                XichuangzhuApplication.getInstance().saveFontStyle(1);
                XichuangzhuApplication.getInstance().textTypefaceChangeNotify();
                break;
        }
    }
}
